package com.hsb.seckill.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 公共返回对象
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResBean {
    private long code;
    private String message;
    private Object obj;

    /**
     * 成功返回结果
     * @return
     */
    public static ResBean success(){
        return new ResBean(ResBeanEnum.SUCCESS.getCode(),ResBeanEnum.SUCCESS.getMessage(),null);
    }

    /**
     * 成功返回结果
     * @param obj 传入一个对象
     * @return
     */
    public static ResBean success(Object obj){
        return new ResBean(ResBeanEnum.SUCCESS.getCode(),ResBeanEnum.SUCCESS.getMessage(),obj);
    }

    /**
     * 失败返回结果
     * @param resBeanEnum
     * @return
     */
    public static ResBean error(ResBeanEnum resBeanEnum){
        return new ResBean(resBeanEnum.getCode(), resBeanEnum.getMessage(),null);
    }

    /**
     * 失败返回结果
     * @param resBeanEnum
     * @param obj
     * @return
     */
    public static ResBean error(ResBeanEnum resBeanEnum,Object obj){
        return new ResBean(resBeanEnum.getCode(), resBeanEnum.getMessage(),obj);
    }
}
